package com.ae.content.enums;

public enum ReturnCodeEnum {

    SUCCESS(0, "success");

    private Integer code;

    private String msg;

    ReturnCodeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static String getMsg(Integer code) {
        ReturnCodeEnum[] returnCodeEnums = values();
        for (ReturnCodeEnum returnCodeEnum : returnCodeEnums) {
            if (returnCodeEnum.getCode().equals(code)) {
                return returnCodeEnum.getMsg();
            }
        }
        return null;
    }

    public static Integer getCode(String msg) {
        ReturnCodeEnum[] returnCodeEnums = values();
        for (ReturnCodeEnum returnCodeEnum : returnCodeEnums) {
            if (returnCodeEnum.getMsg().equals(msg)) {
                return returnCodeEnum.getCode();
            }
        }
        return null;
    }
}
